package com.warm.base.design.b_iterator;

/**
 * @Date: 2019/11/27 16:30
 * @Author: LChuang
 * @Description:
 */
public class ConcreteIterator implements Iterator {

    private ConcreteAggregate aggregate;
    private int index;

    public ConcreteIterator(ConcreteAggregate aggregate){
        this.aggregate = aggregate;
        this.index = 0;
    }

    @Override
    public boolean hasNext() {
        if(index < aggregate.getSize()){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Object next() {
        Object obj = aggregate.get(index);
        index++;
        return obj;
    }
}
